﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class shuangsesw : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected DataTable dt = new DataTable();
    protected DataTable dtPaperList = new DataTable();
    protected DataTable dtPaperList2 = new DataTable();
    protected int jinqiCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        ZoushiManage.FangWenZouShi();
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        }
    }

    protected void bindData(int maxValue)
    {

        int Count = 0;
        arlist = BLL.LotteryAnnouncement.GetPageList_Where(0, maxValue, 1, out  Count);

        if (arlist != null)
        {
            dt.Columns.Add("shou", typeof(string));
            dt.Columns.Add("wei", typeof(string));

            dtPaperList.Columns.Add("Hezhi1", typeof(string));
            dtPaperList.Columns.Add("Hezhi2", typeof(string));
            dtPaperList.Columns.Add("Hezhi3", typeof(string));
            dtPaperList.Columns.Add("Hezhi4", typeof(string));
            dtPaperList.Columns.Add("Hezhi5", typeof(string));
            dtPaperList.Columns.Add("Hezhi6", typeof(string));
            dtPaperList.Columns.Add("Hezhi7", typeof(string));
            dtPaperList.Columns.Add("Hezhi8", typeof(string));
            dtPaperList.Columns.Add("Hezhi9", typeof(string));
            dtPaperList.Columns.Add("Hezhi10", typeof(string));
            dtPaperList.Columns.Add("Hezhi11", typeof(string));
            dtPaperList.Columns.Add("Hezhi12", typeof(string));
            dtPaperList.Columns.Add("Hezhi13", typeof(string));
            dtPaperList.Columns.Add("Hezhi14", typeof(string));
            dtPaperList.Columns.Add("Hezhi15", typeof(string));
            dtPaperList.Columns.Add("Hezhiw1", typeof(string));
            dtPaperList.Columns.Add("Hezhiw2", typeof(string));
            dtPaperList.Columns.Add("Hezhiw3", typeof(string));
            dtPaperList.Columns.Add("Hezhiw4", typeof(string));
            dtPaperList.Columns.Add("Hezhiw5", typeof(string));
            dtPaperList.Columns.Add("Hezhiw6", typeof(string));
            dtPaperList.Columns.Add("Hezhiw7", typeof(string));
            dtPaperList.Columns.Add("Hezhiw8", typeof(string));
            dtPaperList.Columns.Add("Hezhiw9", typeof(string));
            dtPaperList.Columns.Add("Hezhiw10", typeof(string));
            dtPaperList2.Columns.Add("Hezhi1", typeof(string));

            for (int i = 0; i < arlist.Count; i++)
            {
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                 

                int hezhi = 0;//和值 
                int max = 0;
                int min = 35;
                for (int m = 0; m < redBall.Length; m++)
                { 
                    int redBalls=int.Parse(redBall[m]);
                    if (redBalls>max)
                    {
                        max = redBalls;
                    }
                    if (redBalls < min)
                    {
                        min = redBalls;
                    }
                    hezhi += redBalls;
                }
                DataRow nr = dt.NewRow();
                nr["shou"] = max.ToString();
                nr["wei"] = min.ToString();
                dt.Rows.Add(nr);

                hezhi += int.Parse(arlist[i].LotteryNo.Split('+')[1]);
                DataRow newRow = dtPaperList2.NewRow();
                newRow["Hezhi1"] = hezhi.ToString();
                dtPaperList2.Rows.Add(newRow); 

                //计算条形图中每个数的个数
                hezhi = max + min;
                bindTiaoxing(hezhi);
            }
        }
    } 
    protected int[] hezhiDt = new int[25];
    
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[21];
    /// <summary>
    /// 绑定条形码
    /// </summary>
    /// <param name="data">和值</param> 
    protected void bindTiaoxing(int data)
    {
        if (data < 21)
        {
            data=21;
        }
        else if (data >34)
        {
            data = 34; 
        }
        TiaoxingDT[data-21] += 1;
        if (data % 2 == 0)
        {
            TiaoxingDT[14] += 1; //双
        }
        else
        {
            TiaoxingDT[15] += 1; //单
        }
        if (data <= 27)
        {
            TiaoxingDT[16] += 1;  //大 
        }
        else if (data >= 28)
        {
            TiaoxingDT[17] += 1;//小 
        }
        if (data % 3 == 0)
        {
            TiaoxingDT[18] += 1;//三路0
        }
        else if (data % 3 == 1)
        {
             TiaoxingDT[19] +=1;//三路1
        }
        else if (data % 3 == 2)
        {
             TiaoxingDT[20] +=1;//三路2
        }  
    }
}